<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>转移审核</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
</head>
<%@include file="../include/header.jsp" %>
<body>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <section>
        <div class="section-main">
            <div class="layui-tab layui-tab-brief mt20" lay-filter="type">
                <ul class="layui-tab-title">
                    <ul class="layui-tab-title" id="type_tab">
                        <li <c:if test="${type == 0}">class="layui-this"</c:if>>
                            待审核${auditINGTotal}</span>人
                        </li>
                        <li <c:if test="${type == 1}">class="layui-this"</c:if>>
                            已审核${auditEDTotal}</span>人
                        </li>
                    </ul>
                </ul>
                <div class="layui-tab-content">
                    <form class="layui-form" action="${ctx}/audit/transfer/detail.do?" id="myForm" method="post">
                        <input type="hidden" name="pageNo" id="pageNo"/>
                        <input type="hidden" name="eId" value="${eId}"/>
                        <input type="hidden" id="type" name="type" value="${type}"/>
                        <div class="f-search-bar">
                            <div class="search-container">
                                <ul class="search-form-content">
                                    <li class="form-item-inline"><label class="search-form-lable">众筹者</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="authorName" autocomplete="off" class="layui-input"
                                                   value="${projectWithAuthor.authorName}"
                                                   placeholder="众筹者">
                                        </div>
                                    </li>
                                    <li class="form-item-inline"><label class="search-form-lable">联系电话</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="authorMobile" autocomplete="off"
                                                   class="layui-input" value="${projectWithAuthor.authorMobile}"
                                                   placeholder="联系电话">
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <div class="sub-btns">
                                            <a class="layui-btn layui-btn-danger"
                                               href="javascript:submitFunctionNew('#myForm')">查询</a>
                                            <a class="layui-btn layui-btn-normal"
                                               href="javascript:resetFunction('#myForm')">重置</a>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </form>
                    <div class="my-act-list-content">
                        <div class="cl">
                            <table class="layui-table">
                                <colgroup>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>众筹者</th>
                                    <th>渠道</th>
                                    <th>公司</th>
                                    <th>区域</th>
                                    <th>职务</th>
                                    <th>联系电话</th>
                                    <th>支持人数</th>
                                    <th>支持金额</th>
                                    <th>真实金额</th>
                                    <th>转移状态</th>
                                    <th>
                                        <c:if test="${type == 0}">编辑</c:if>
                                        <c:if test="${type == 1}">操作时间</c:if>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach var="crowdfund" items="${list}">
                                    <tr class="detail-content">
                                        <td class="table-member"
                                            onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${crowdfund.authorId}','400px','470px')">
                                            <div class="member-cell">
                                                <div class="member-logo common-img">
                                                    <img src="<c:if test="${ crowdfund.authorLogo!= null}">${crowdfund.authorLogo}?imageMogr2/auto-orient/crop/126x126</c:if>"
                                                         alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                                </div>
                                                <div class="member-name ellipsis-1"><a class="blue"
                                                                                       title="${crowdfund.authorName}"
                                                                                       href="javascript:void(0);">${crowdfund.authorName}</a>
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="ellipsis-1"
                                                 title="${crowdfund.publisher}">${crowdfund.publisher}</div>
                                        </td>
                                        <td>
                                            <div class="ellipsis-1"
                                                 title="${crowdfund.authorCompany}">${crowdfund.authorCompany}</div>
                                        </td>
                                        <td>
                                                ${crowdfund.cityName}
                                        </td>
                                        <td>
                                            <div class="ellipsis-1">
                                                    ${crowdfund.authorJobTitle}
                                            </div>
                                        </td>
                                        <td>
                                                ${crowdfund.authorMobile}
                                        </td>
                                        <td>
                                                <%--<a href="javascript:void(0);" class="blue ${crowdfund.actualAmount > 0 ||crowdfund.isSuccess == 4 ? 'favorerNum' : ''} count-num"
                                                   data-id="${crowdfund.id}"
                                                   data-name="${crowdfund.authorName}">--%>${crowdfund.favorerNum}<%--</a>--%>
                                        </td>
                                        <td>
                                                <%-- <a href="javascript:void(0);"
                                                    class="blue ${crowdfund.actualAmount > 0 ||crowdfund.isSuccess == 4 ? 'actualAmount' : ''} count-num"
                                                    data-id="${crowdfund.id}"
                                                    data-name="${crowdfund.authorName}">--%> ${crowdfund.actualAmount}<%--</a>--%>

                                        </td>
                                        <td>
                                            <c:if test="${empty crowdfund.realTimeAmount || null == crowdfund.realTimeAmount}">
                                                0.0
                                            </c:if>
                                            <c:if test="${ not empty crowdfund.realTimeAmount || null != crowdfund.realTimeAmount}">
                                                ${crowdfund.realTimeAmount}
                                            </c:if>
                                        </td>
                                        <td>
                                            <a href="javascript:getTargetProjectName('${crowdfund.id}')">
                                                        <span>
                                                        <c:choose>
                                                            <c:when test="${crowdfund.transferStatus == 3}">
                                                                待审核
                                                            </c:when>
                                                            <c:when test="${crowdfund.transferStatus == 4}">
                                                                审核通过
                                                            </c:when>
                                                            <c:when test="${crowdfund.transferStatus == 5}">
                                                                审核拒绝
                                                            </c:when>
                                                        </c:choose>
                                                         </span>
                                            </a>
                                        </td>
                                        <c:if test="${type == 0}">
                                            <td class="opts-btns tb-opts">
                                                <div class="comm-opts">
                                                    <a class="green"
                                                       href="javascript:check('确认要审核通过吗？','${crowdfund.id}', '${crowdfund.actId}','0')"
                                                       target="_self">通过</a>
                                                    <a class="red"
                                                       href="javascript:check('确认要审核拒绝吗？','${crowdfund.id}','${crowdfund.actId}', '1')"
                                                       target="_self">拒绝</a>
                                                </div>
                                            </td>
                                        </c:if>
                                        <c:if test="${type == 1}">
                                            <td>
                                                <fmt:formatDate value="${crowdfund.updateDate}"
                                                                pattern="yyyy-MM-dd hh:mm:ss"/>
                                            </td>
                                        </c:if>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div>
        <%@include file="../include/footer.jsp" %>
    </section>
</div>


<div id="targetProjectDiv">
    <table class="layui-table" lay-skin="line">
        <tbody>
        <tr>
            <td class="table-member">
                <div class="member-cell">
                    <li>
                        <ul class="member-name ellipsis-1">

                        </ul>
                    </li>
                </div>
            </td>
        </tr>
        </tbody>
    </table>
</div>

<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript" src="${ctx}/script/common/list.js"></script>

<script type="text/javascript">
    var laytpl = null;
    var laypage = null;
    var element = null;
    var form = null;
    txz.initHeader({
        nav: [{
            name: '转移审核',
            curr: true
        }, {
            name: '${ceObj.name}'
        }],
        info: '',
        btns: [{
            name: '返回',
            href: '${ctx}/audit/transfer/list.do',
            icon: 'back'
        }]
    });
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use(['laytpl', 'laypage', 'element', 'form'], function () {
            laytpl = layui.laytpl;
            laypage = layui.laypage;
            element = layui.element;
            form = layui.form;

            element.on('tab(type)', function (data) {
                console.log(data)
                if (data.index == 0) {
                    $('#type').val(0);
                    $("[name=partnerId]").find("option:selected").val("");
                    $('#myForm').submit();
                } else if (data.index == 1) {
                    $('#type').val(1);
                    $("[name=partnerId]").find("option:selected").val("");
                    $('#myForm').submit();
                }
            });
        });

        $('.favorerNum').click(function () {
            var projectId = $('#type').value
            var name = this.dataset.name;
            window.location.href = '${ctx}/crowdfund/support/listForProjectId.do?id=${crowdfund.actId}&projectId=' + projectId;
        });

        $('.actualAmount').click(function () {
            var projectId = this.dataset.id;
            var name = this.dataset.name;
            window.location.href = '${ctx}/crowdfund/support/listForProjectId.do?id=${crowdfund.actId}&projectId=' + projectId;
        });

    })

    function openDialog(title, url, width, height, target) {
        layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: true, //开启最大化最小化按钮
            content: url,
            btn: ['确定', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function () {
                        top.layer.close(index);
                    }, 100);//延时0.1秒，对应360 7.1版本bug

                    setTimeout(function () {
                        window.location.reload();
                    }, 200);
                }

            },
            cancel: function (index) {
            }
        });
    }

    function check(content, sourceId, targetId, checkStatus) {
        layer.confirm(content, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/audit/transfer/verify.do", {
                sourceId: sourceId,
                targetId: targetId,
                checkStatus: checkStatus
            }, function (data) {
                layer.close(loadIndex);
                setTimeout(function () {
                    if (data.success == true) {
                        util.layerAlertSuccess("已审核", function () {
                            window.location.reload();
                        })
                    } else {
                        util.layerAlertError("审核失败，请检查目标活动的状态和金额")
                    }
                }, 500);
            })
        });
    }

    function getTargetProjectName(sourceId) {
        var setPayIndex = layer.open({
            type: 1,
            area: '450px',
            title: '查看目标项目',
            content: $("#targetProjectDiv"),
            btn: ['关闭'],
            success: function () { // 弹出后回调
                $.post('${ctx}/crowdfund/project/getTargetProject.do', {
                    sourceId: sourceId
                }, function (res) {
                    if (res.success) {
                        var projectName = res.data.projectName;
                        $("#targetProjectDiv").find(".member-name").text(projectName);
                    } else {
                        util.layerMsgError(res.description)
                    }
                })
            },
            end: function () { // 销毁后回调
                $("#targetProjectDiv").find(".member-name").text('');
            },
            yes: function () { // 确定按钮
                layer.close(setPayIndex);
            }
        });
    }
</script>
</body>
</html>
